<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>选择元素和绑定数据</title>
	<script src="d3/d3.v3.min.js" charset="utf-8"></script>
	<style>
		
	</style>
</head>
<body>
	
	
<p>Apple</p>
<p>Pear</p>
<p>Banana</p>




</body>
<script type="text/javascript">


var dataset = ["I like dog","I like cat","I like snake"];
var body = d3.select("body");
var p = body.selectAll("p");

//console.log(p[0][1].innerHTML);

p.data(dataset)
	.text(function(d, i){
		return "第 "+ i + " 个元素 "+p[0][i].innerHTML+" 绑定的数据是 " + d;
//		return d;
	});

</script>
</html>
